<template>
  <base-breadcrumb>
    <searchData :searchData="searchArr" @search="search"></searchData>
    <a-card>
      <div class="table-operator">
        <a-button type="primary" icon="plus" @click="handleAdd()">新增会议</a-button>
      </div>
      <s-table
        bordered
        ref="table"
        size="default"
        rowKey="key"
        :columns="columns"
        :data="loadData"
        :alert="true"
        show-size-changer
        show-quick-jumper
        showPagination="auto"
      >
        <!-- <span slot="operation" slot-scope="text, record">
          <a @click="detailed(record)">查看</a>
          <a-divider v-if="record.auditStatus == 'DRAFT'" type="vertical" />
          <a @click="addEdit(record)" v-if="record.auditStatus == 'DRAFT'">填写纪要</a> -->
          <!-- <a-divider v-if="record.auditStatus == 'DRAFT'" type="vertical" />
          <a @click="deleteDraft(record)" v-if="record.auditStatus == 'DRAFT'">删除</a>-->
        <!-- </span> -->
        <!-- <span slot="auditStatus" slot-scope="text,record">
          <ul v-if="record.step === 'DRAFT'" class="not-submit">
            <li>草稿</li>
          </ul>
          <ul v-if="record.auditStatus === 'SUBMITTED'" class="not-submit">
            <li>已提交</li>
          </ul>
          <ul v-if="record.auditStatus === 'PAST'" class="not-submit">
            <li>通过</li>
          </ul>
          <ul v-if="record.auditStatus === 'REJECTED'" class="not-submit">
            <li>驳回</li>
          </ul>
        </span> -->
      </s-table>
    </a-card>
  </base-breadcrumb>
</template>
<script>
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 项目
import OrgTreeSelect from '@/components/OrgTreeSelect'
import SelectSubcontractor from '@/components/Select/SelectSubcontractor' // 项目
import { STable } from '@/components'
const columns = [
    {
        title: '验收部位',
        dataIndex: 'name',
    },
    {
        title: '验收分类',
        dataIndex: 'branchComName',
    },
    {
        title: '所属分公司',
        dataIndex: 'projectName',
    },
    {
        title: '所属项目',
        dataIndex: 'time',
    },
    {
        title: '计划时间',
        dataIndex: 'creatorName',
    },
    {
        title: '实际时间',
        dataIndex: 'creatorName',
    },
    {
        title: '分包单位名称',
        dataIndex: 'createTime',
    },
    {
        title: '验收负责人',
        dataIndex: 'createTime',
    },

    {
        title: '状态',
        dataIndex: 'auditStatus',
        scopedSlots: { customRender: 'auditStatus' },
    },
    {
        title: '操作',
        dataIndex: 'operation',
        width: '170px',
        scopedSlots: { customRender: 'operation' },
    },
]
const searchArr = [
    // {
    //     name: '所属分公司',
    //     valueKey: 'branchComId',
    //     type: SelectSubCompany,
    // },
    {
          name: '所属单位',
          valueKey: 'searchQuery',
          type: OrgTreeSelect,
        },
    // {
    //     name: '所属项目',
    //     keyValue: 'branchComId',
    //     valueKey: 'projectId',
    //     type: SelectProject,
    // },
    {
        name: '分包单位',
        keyValue: 'projectId',
        valueKey: 'subContractorId',
        type: SelectSubcontractor,
    },
    {
        name: '验收类别',
        value: 'creatorName',
        type: 'select',
        data: [],
    },
    {
        name: '验收月份',
        value: 'startEndDate',
        type: 'month',
    },
    {
        name: '验收部位',
        value: 'startEndDate',
        type: 'input',
    },
    {
        name: '填报人',
        value: 'startEndDate',
        type: 'input',
    },
    {
        name: '填报时间',
        value: 'startEndDate',
        type: 'dateRange',
    },
]
export default {
    name:'a'+Date.now(),    components: {
        STable,
    },
    data() {
        this.columns = columns
        this.searchArr = searchArr
        return {
            queryParam: {},

            loadData: (parameter) => {
                const requestParameters = Object.assign({}, parameter, this.queryParam)

                if (this.queryParam.startEndDate) {
                    requestParameters.TimeBegin = this.queryParam.startEndDate[0]
                    requestParameters.createTimeEnd = this.queryParam.startEndDate[1]
                }

                // return getProjectTotalApprovalList(requestParameters).then((res) => {
                //     console.log('数据返回对象：', res)
                //     return res
                // })
            },
        }
    },
    methods: {
        //搜索
        search(value) {
            console.log(value)
            this.queryParam = value
            this.$refs.table.refresh(true)
        },
        //新增
        handleAdd() {
            //添加会议
            // this.$router.push({
            //     name: 'AddConference',
            // })
            // 进入会议
            this.$router.push({
                name: 'InMeeting',
            })
            // 查看会议
            this.$router.push({
                name: 'MeetingDetail',
            })
        },
        // 查看
        detailed(e) {
            this.$router.push({
                path: '/businessAffairs/projectTotalApproval/projectTotalApprovalDetail',
                query: {
                    id: e.id,
                },
            })
        },
        //编辑
        addEdit(e) {
            this.$router.push({
                path: '/businessAffairs/projectTotalApproval/projectTotalApprovalAdd',
                query: {
                    id: e.id,
                },
            })
        },

        // 删除草稿
        deleteDraft(e) {
            deleteProjectTotalApproval(e).then((res) => {
                console.log(res)
                if (res.data.code == '200') {
                    this.$message.success('删除成功')
                    this.getProjectTotalApprovalList()
                }
            })
        },
    },
}
</script>
